// pages/identity/identity.js
const host=getApp().host;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    admin:{},
    date:'',
    imgSrc:'',
    info:'',
    title:''
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let info=wx.getStorageSync('userInfo');
    let admin=wx.getStorageSync('admin');
    this.setData({
      info:info,
      admin:admin
    },()=>{
      this.init();
    })
  },

  /**初始化身份码 */
  init(){
    this.setData({
      imgSrc:host+'/client/userInfo/qrcode?userId='+this.data.admin.loginName
    })
  }, 

  /**格式化日期 */ formatDate(row) {
    let date = new Date(row);
    let month =
          date.getMonth() + 1 < 10
                ? "0" + (date.getMonth() + 1)
                : date.getMonth() + 1;
    let day =
          date.getDate() < 10
                ? "0" + date.getDate()
                : date.getDate();
    let hours =
          date.getHours() < 10
                ? "0" + date.getHours()
                : date.getHours();
    let minutes =
          date.getMinutes() < 10
                ? "0" + date.getMinutes()
                : date.getMinutes();
    return (
          date.getFullYear() +
          "-" +
          month +
          "-" +
          day +
          " " +
          hours +
          ":" +
          minutes
    );
},
})